<template>
  <div class="coordinate-form">
    <!-- <Dialog :title="dialogTitle" v-model="dialogVisible">
      <template #footer>
        <el-button @click="submitFormDB" type="primary" :disabled="formLoading">确 定</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>
      </template>
    </Dialog> -->
    <SmForm
      class="-mb-15px"
      ref="formRef"
      isCols
      label-width="150px"
      v-model="formData"
      v-loading="formLoading"
      :options="requestFormOptions"
      :getModelValue="getFormData"
    >
      <!-- <template #authTree>
          <el-tree
            ref="permTreeRef"
            node-key="value"
            show-checkbox
            :data="menuTree"
            :filter-node-method="handlePermFilter"
            :check-strictly="false"
            class="mt-5"
            @check="check"
          >
            <template #default="{ data }">
              {{ data.label }}
            </template>
          </el-tree>
        </template> -->
      <template #idCard>
        <MultiImageUpload
          v-model="formData.imgList"
          :limit="1"
          @update:model-value="(val) => changeOneImg(val, formData, 'idCard')"
        />
      </template>
      <template #businessLicense>
        <MultiImageUpload
          v-model="formData.imgList1"
          :limit="1"
          @update:model-value="(val) => changeOneImg(val, formData, 'businessLicense')"
        />
      </template>

      <template #drivelicenseFront>
        <MultiImageUpload
          v-model="formData.imgList"
          :limit="1"
          @update:model-value="(val) => changeOneImg(val, formData, 'drivelicenseFront')"
        />
      </template>
      <template #drivelicenseReverse>
        <MultiImageUpload
          v-model="formData.imgList1"
          :limit="1"
          @update:model-value="(val) => changeOneImg(val, formData, 'drivelicenseReverse')"
        />
      </template>

      <template #coordinateItems>
        <SmTable
          border
          :options="coordinateItemsOptions"
          :data="coordinateItemslist"
          :pagination="false"
        >
          <template #field7="{ scope }">
            <el-checkbox v-model="scope.row.checked" :label="scope.row.field7" />
          </template>
          <template #field8="{ scope }">
            <SmSelect v-model="scope.row.field8" :data="mockCoordinateList" />
          </template>
        </SmTable>
      </template>

      <template #field29>
        <FileUpload
          v-model="formData.fileList"
          @update:model-value="(val) => changeFilesData(val, formData, 'field29')"
        />
      </template>

      <template #action>
        <el-button @click="submitFormDB" type="primary" :disabled="formLoading">确 定</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>
      </template>
    </SmForm>
  </div>
</template>
<script setup lang="ts">
import { createUser, getRoleList, getUser, updateUser } from "@/api/user";
import { addProperty } from "@/components/SmForm/src/utils";
import { createDBFn } from "@/utils/decorate";
import { defaultProps } from "@/utils/tree";
// import { mockTreeList } from "./data";
import {
  getCoordinateTypeList,
  getDeptTree,
  getInvoiceList,
  getOrganizationList,
  getProvinceCityDistrictList,
  getUserList,
} from "@/commonData";
// import { useAuth } from "../hooks/useAuth";
import DeptAPI from "@/api/system/dept-api";
import {
  coordinateDealMethodsList,
  certTypeList,
  enableList,
  invoiceTypeList,
  payList,
  relationshipList,
  unitList,
} from "@/commonData/dict";
import { changeOneImg } from "@/utils/changeData";
import { phoneRules } from "@/commonData/rules";
import { useTableData } from "@/components/SmTable/src/utils";
import { changeFilesData } from "@/utils/changeData";

const mockCoordinateList = [
  { label: "1000", value: "1000" },
  { label: "100万", value: "100万" },
  { label: "200万", value: "200万" },
];

const coordinateItemsFieldMap = {
  field7: {
    label: "统筹项目",
    slot: "field7",
  },
  field8: {
    label: "统筹额度",
    slot: "field8",
  },
  field9: "标准统筹费",
  field10: "政策折扣率(%)",
  field11: "应缴统筹费",
};
const { tableOptions: coordinateItemsOptions, transformTableOptions } = useTableData();
coordinateItemsOptions.value = transformTableOptions(coordinateItemsFieldMap);
const coordinateItemslist: any = ref([]);
for (let i = 0; i < 10; i++) {
  const obj: any = {};
  coordinateItemsOptions.value.forEach((item: any, index) => {
    obj[item.prop] = "这是测试数据" + index;
  });
  coordinateItemslist.value.push(obj);
}

/** 仓库 表单 */
defineOptions({ name: "CoordinateForm" });

const { t } = useI18n(); // 国际化

const dialogVisible = ref(false); // 弹窗的是否展示
const dialogTitle = ref("统筹信息"); // 弹窗的标题
const formLoading = ref(false); // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用
const formType = ref(""); // 表单的类型：create - 新增；update - 修改
const initDefaultData = () => {
  return {
    guaranteeNum: 365,
  };
};
const initFormData = () => {
  const defaultData = initDefaultData();
  const data = {};
  Object.assign(data, defaultData);
  return data;
};
const formData: any = ref(initFormData());
const formRef = ref(); // 表单 Ref
const deptTree = ref([]);
const organizationList = ref([]);
const coordinateTypeList = ref([]);
const userList = ref([]);
const { provinceList, cityList, districtList } = getProvinceCityDistrictList(formData, formRef);
const invoiceList = ref([]);

// const {
//   isExpanded,
//   permKeywords,
//   checkedRole,
//   permTreeRef,
//   getMenuTreeAndRoleMenu,
//   menuTree,

//   setRoleMenu,
//   handlePermFilter,
//   togglePermTree,
//   handleAssignPermSubmit,
// } = useAuth();

// 只有选中时才有-调用接口拿到的时候也需要加
const check = (checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys) => {
  formData.value.menuIds = checkedKeys?.checkedKeys;
  console.log(
    checkedNodes,
    checkedKeys,
    halfCheckedNodes,
    halfCheckedKeys,
    "checkedNodes,checkedKeys,halfCheckedNodes,halfCheckedKeys"
  );
};

/** 打开弹窗 */
const open = async (type: string, id?: string) => {
  dialogVisible.value = true;
  // dialogTitle.value = t("action." + type);
  formType.value = type;
  resetForm();

  getOrganizationList(organizationList);

  getDeptTree(deptTree);
  getCoordinateTypeList(coordinateTypeList);
  getUserList(userList);
  getInvoiceList(invoiceList);

  // if (!id) {
  //   getMenuTreeAndRoleMenu();
  // }

  // 修改时，设置数据
  if (id) {
    formLoading.value = true;
    try {
      const data = await DeptAPI.getFormData(id);
      const defaultData = initDefaultData();
      Object.assign(data, defaultData);
      formRef.value = data;

      // getMenuTreeAndRoleMenu(formData.value);
      // 主动触发表单数据回显
      formRef.value.initForm();
    } finally {
      formLoading.value = false;
    }
  }
};
defineExpose({ open }); // 提供 open 方法，用于打开弹窗

/** 提交表单 */
const emit = defineEmits(["success"]); // 定义 success 事件，用于操作成功后的回调
const submitForm = async () => {
  // 校验表单
  await formRef.value.validate();
  // 提交请求
  formLoading.value = true;
  try {
    const data = formData.value as unknown as any;
    if (formType.value === "create") {
      await createUser(data);
      // ElMessage.success("操作成功");
    } else if (formType.value === "update") {
      await updateUser(data);
      // ElMessage.success("操作成功");
    }
    ElMessage.success("操作成功");
    dialogVisible.value = false;
    // 发送操作成功的事件
    emit("success");
  } finally {
    formLoading.value = false;
  }
};
const submitFormDB = createDBFn(submitForm);

/** 重置表单 */
const resetForm = () => {
  formData.value = initFormData();
  formRef.value?.resetFields();
};

const requestFormOptions: any = ref([]);

const createRequestFormOptions = () => {
  // 1、部门名称-name
  // 2、部门编码-code
  // 3、归属机构-orgId
  // 4、上级部门-parentId
  // 5、部门描述-desc
  // 6、权限设置
  // 只有部门描述和权限设置非必填
  //   [
  //     {
  //         "id": "1",
  //         "parentId": "0",
  //         "name": "有来技术",
  //         "code": "YOULAI",
  //         "sort": 1,
  //         "status": 1,
  //         "children": [],
  //         "createTime": null,
  //         "updateTime": "2024-06-24 23:48"
  //     }
  // ]

  /*
    和后端讨论下存id-123-还是存字符串

    1-承统机构-下拉单-必填-orgId-1
    2-承统单位-下拉单-字典-必填-unitId-1
    3-支付方式-下拉单-字典-必填 payId-1
    4-投统(支付)日期 payDate-1
    5-统筹分类-下拉单-必填 coordinateTypeId-1
    6-选择代理人-下拉单-必填 agentUserId
    7-统筹单号-手输-7-统筹单号-手输-或者直接调用接口生成-必填 coordinateNo
    8-统筹合同争议解决方式-字典-必填 coordinateDealMethodsId-1
    9-*统筹起始日-统筹起始日-必填 coordinateStartDate-1
    10-*统筹到期日-统筹终止日-必填  coordinateEndDate-1
    11-保障天数	365天-写死 guaranteeNum-1
    12-制单人-手输-必填 creatName-1
    12-经办单位-手输-必填 handleUnit-1
    13-特别约定-文本域 specialAgreement-1
    14-是否需要上传验车照-下拉 isNeedCarPhoto-1
    15-是否已上传验车照 isAlreadyCarPhoto-1
    16-验车要求-文本域 carRequirements-1

  */
  // 统筹信息
  const planList = [
    {
      requiredFlag: true,
      type: "tree-select",
      placeholder: "承统机构",
      prop: "orgId",
      label: "承统机构",
      attrs: {
        filterable: true,
        clearable: true,
        data: organizationList,
        props: defaultProps,
        "check-strictly": true,
        "node-key": "id",
      },
    },
    {
      requiredFlag: true,
      type: "select",
      placeholder: "承统单位",
      prop: "unit",
      label: "承统单位",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: unitList,
    },
    {
      requiredFlag: true,
      type: "select",
      placeholder: "支付方式",
      prop: "pay",
      label: "支付方式",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: payList,
    },
    {
      type: "date-picker",
      placeholder: "投统(支付)日期",
      prop: "payTime",
      label: "投统(支付)日期",
      attrs: {
        clearable: true,
        type: "date",
        "range-separator": "~",
        editable: false,
        "value-format": "YYYY-MM-DD",
      },
    },
    {
      requiredFlag: true,
      type: "select",
      placeholder: "统筹分类",
      prop: "coordinateTypeId",
      label: "统筹分类",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: coordinateTypeList,
    },
    {
      requiredFlag: true,
      type: "select",
      placeholder: "代理人",
      prop: "agentUserId",
      label: "代理人",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: userList,
    },
    {
      requiredFlag: true,
      type: "input",
      label: "统筹单号",
      prop: "coordinateNo",
      placeholder: "统筹单号",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      requiredFlag: true,
      type: "select",
      placeholder: "统筹合同争议解决方式",
      prop: "coordinateDealMethods",
      label: "统筹合同争议解决方式",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: coordinateDealMethodsList,
    },
    {
      type: "date-picker",
      placeholder: "统筹起始日",
      prop: "coordinateStartDate",
      label: "统筹起始日",
      attrs: {
        clearable: true,
        type: "date",
        "range-separator": "~",
        editable: false,
        "value-format": "YYYY-MM-DD",
      },
    },
    {
      type: "date-picker",
      placeholder: "统筹到期日",
      prop: "coordinateEndDate",
      label: "统筹到期日",
      attrs: {
        clearable: true,
        type: "date",
        "range-separator": "~",
        editable: false,
        "value-format": "YYYY-MM-DD",
      },
    },

    {
      type: "input-number",
      label: "保障天数",
      prop: "guaranteeNum",
      attrs: {
        disabled: true,
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
        style: {
          width: "100%",
        },
      },
    },

    {
      requiredFlag: true,
      type: "input",
      label: "制单人",
      prop: "creatName",
      placeholder: "制单人",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      requiredFlag: true,
      type: "input",
      label: "经办单位",
      prop: "handleUnit",
      placeholder: "经办单位",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "特别约定",
      prop: "specialAgreement",
      placeholder: "特别约定",
      attrs: {
        type: "textarea",
        style: { width: "100%" },
        clearable: true,
      },
    },

    {
      type: "select",
      placeholder: "是否需要上传验车照",
      prop: "isNeedCarPhoto",
      label: "是否需要上传验车照",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: enableList,
    },
    {
      type: "select",
      placeholder: "是否已上传验车照",
      prop: "isAlreadyCarPhoto",
      label: "是否已上传验车照",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: enableList,
    },
    {
      type: "input",
      label: "验车要求",
      prop: "carRequirements",
      placeholder: "验车要求",
      attrs: {
        type: "textarea",
        style: { width: "100%" },
        clearable: true,
      },
    },
    // {
    //   slot: "authTree",
    //   label: "权限设置",
    // },
  ];

  /**
   1- 客户-下拉-单选-customerId-1
   2-身份证 idCard-上传图片-1
   3-营业执照 businessLicense-上传图片-1
   4-姓名-手输--name-1
   5-证件类型-下拉框-字典-单选-documentType-1
   6-证件号码-手输-documentNum-1
   7-省市区-provice-city-district-下拉单选
   8-手机号-phone-手输-1
   9-详细地址-address-手输-1
   10-参统人是被统筹人的-relationship-下拉单选-字典-1

   */
  // 参统人信息
  const participantList = [
    {
      type: "select",
      placeholder: "客户",
      prop: "customerId",
      label: "客户",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: userList,
    },
    {
      slot: "idCard",
      label: "身份证",
    },
    {
      slot: "businessLicense",
      label: "营业执照",
    },
    {
      type: "input",
      label: "姓名",
      prop: "name",
      placeholder: "姓名",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "select",
      placeholder: "证件类型",
      prop: "documentType",
      label: "证件类型",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: certTypeList,
    },
    {
      type: "input",
      label: "证件号码",
      prop: "documentNum",
      attrs: {
        clearable: true,
        style: {
          width: "100%",
        },
      },
    },

    {
      type: "select",
      placeholder: "省",
      prop: "province",
      label: "省",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: provinceList,
    },
    {
      type: "select",
      placeholder: "市",
      prop: "city",
      label: "市",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: cityList,
    },
    {
      type: "select",
      placeholder: "区",
      prop: "district",
      label: "区",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: districtList,
    },
    {
      type: "input",
      label: "手机号",
      prop: "phone",
      placeholder: "手机号",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
      rules: phoneRules,
    },
    {
      type: "input",
      label: "详细地址",
      prop: "address",
      attrs: {
        clearable: true,
        style: {
          width: "100%",
        },
      },
    },
    {
      type: "select",
      placeholder: "参统人是被统筹人的",
      prop: "relationship",
      label: "参统人是被统筹人的",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: relationshipList,
    },
  ];

  /*3、代理签署人信息

    1、同投统人-下拉单选 proxySignUserId
    2、姓名-手输 proxySignName
    3、证件类型-字典下拉 proxySignDocumentType
    4、证件号码-手输 proxySignDocumentNum
    5、手机-手输* proxySignPhone
    */

  const proxySignList = [
    {
      type: "select",
      placeholder: "同投统人",
      prop: "proxySignUserId",
      label: "同投统人",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: userList,
    },
    {
      type: "input",
      placeholder: "姓名",
      label: "姓名",
      prop: "proxySignName",
      attrs: {
        clearable: true,
        style: {
          width: "100%",
        },
      },
    },
    {
      type: "select",
      placeholder: "证件类型",
      label: "证件类型",
      prop: "proxySignDocumentType",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: certTypeList,
    },
    {
      type: "input",
      placeholder: "证件号码",
      label: "证件号码",
      prop: "proxySignDocumentNum",
      attrs: {
        clearable: true,
        style: {
          width: "100%",
        },
      },
    },
    {
      type: "input",
      label: "手机",
      prop: "proxySignPhone",
      placeholder: "手机",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
      rules: phoneRules,
    },
  ];

  /**
   *4 车辆信息
    1、上传行驶证正面-drivelicenseFront-1
    2、上传行驶证反面-drivelicenseReverse-1
   
    3、车牌号-手输-必填-carNum-1
    4、车架号-手输-必填-vinNum-1
    5、发动机号-手输-必填-engineNum-1
    6、厂牌型号(中央型号-按钮列表查询)-手输-必填-brandModel-1
    7、车辆性质-下拉-必填-字典-carNature-1
    8、车辆种类-下拉-必填-字典-carType-1
    9、号牌种类-下拉-必填-字典-numType-1
    10、总质量(kg)-手输-totalWeight-1
    11、整备质量(kg)-手输-prepareWeight-1
    12、额定载重量(kg)-手输-ratedWeight-1
    13、核定载质(kg)-手输approvedWeight-1
    14、核定人数(人)-手输approvedManNum-1
    15、排量(L)-手输-displacement-1
    16、功率(KW)-手输-power-1
    17、新车购置价(元) newCarPrice-1
    18、车辆实际价值(元) newCarRealPrice-1
    19、登记日期 -registeDate-1-1
    20、是否过户-下拉 isTransferOwnership-1
    21、过户日期-transferOwnershipDate-1
    22、行驶区域-手输-driveArea-1
    23、已使用年限(年)-serviceYears-1
    24、年平均行驶里程-annualAeragemile-1

    车主信息(同统筹人 同被统筹人)
    25、同统筹人-下拉单选 -coordinatorUserId-1
    26、同被统筹人-下拉单选 byCordinatorUserId-1
    27、车主姓名-carName-1
    28、车主手机-carPhone-1
    29、车主证件类型-字典-下拉单选 carDcumentType
    30、车主地址-carAddress
    31、车主证件号码carIdNum

   */

  const carList = [
    {
      slot: "drivelicenseFront",
      label: "身上传行驶证正面",
    },
    {
      slot: "drivelicenseReverse",
      label: "上传行驶证反面",
    },
    {
      requiredFlag: true,
      type: "input",
      placeholder: "车牌号",
      label: "车牌号",
      prop: "carNum",
      attrs: {
        clearable: true,
        style: {
          width: "100%",
        },
      },
    },
    {
      requiredFlag: true,
      type: "input",
      placeholder: "车架号",
      label: "车架号",
      prop: "vinNum",
      attrs: {
        clearable: true,
        style: {
          width: "100%",
        },
      },
    },
    {
      requiredFlag: true,
      type: "input",
      placeholder: "发动机号",
      label: "发动机号",
      prop: "engineNum",
      attrs: {
        clearable: true,
        style: {
          width: "100%",
        },
      },
    },
    {
      requiredFlag: true,
      type: "input",
      placeholder: "发动机号",
      label: "发动机号",
      prop: "engineNum",
      attrs: {
        clearable: true,
        style: {
          width: "100%",
        },
      },
    },
    {
      requiredFlag: true,
      type: "input",
      placeholder: "厂牌型号",
      label: "厂牌型号",
      prop: "brandModel",
      attrs: {
        clearable: true,
        style: {
          width: "100%",
        },
      },
    },
    {
      requiredFlag: true,
      type: "select",
      placeholder: "车辆性质",
      label: "车辆性质",
      prop: "carNature",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: certTypeList,
    },
    {
      requiredFlag: true,
      type: "select",
      placeholder: "车辆种类",
      label: "车辆种类",
      prop: "carType",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: certTypeList,
    },
    {
      requiredFlag: true,
      type: "select",
      placeholder: "号牌种类",
      label: "号牌种类",
      prop: "numType",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: certTypeList,
    },
    {
      type: "input-number",
      label: "总质量(kg)",
      prop: "totalWeight",
      placeholder: "总质量(kg)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 2,
      },
    },
    {
      type: "input-number",
      label: "整备质量(kg)",
      prop: "prepareWeight",
      placeholder: "整备质量(kg)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 2,
      },
    },
    {
      type: "input-number",
      label: "额定载重量(kg)",
      prop: "ratedWeight",
      placeholder: "额定载重量(kg)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 2,
      },
    },
    {
      type: "input-number",
      label: "核定载质(kg)",
      prop: "approvedWeight",
      placeholder: "核定载质(kg)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 2,
      },
    },
    {
      type: "input-number",
      label: "核定人数(人)",
      prop: "approvedManNum",
      placeholder: "核定人数(人)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    {
      type: "input-number",
      label: "排量(L)",
      prop: "displacement",
      placeholder: "排量(L)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    {
      type: "input-number",
      label: "功率(KW)",
      prop: "power",
      placeholder: "功率(KW)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },

    {
      type: "input-number",
      label: "新车购置价(元)",
      prop: "newCarPrice",
      placeholder: "新车购置价(元)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 2,
      },
    },
    {
      type: "input-number",
      label: "车辆实际价值(元)",
      prop: "newCarRealPrice",
      placeholder: "车辆实际价值(元)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 2,
      },
    },
    {
      type: "date-picker",
      placeholder: "登记日期",
      prop: "registeDate",
      label: "登记日期",
      attrs: {
        clearable: true,
        type: "date",
        "range-separator": "~",
        editable: false,
        "value-format": "YYYY-MM-DD",
      },
    },
    {
      type: "select",
      placeholder: "是否过户",
      label: "是否过户",
      prop: "isTransferOwnership",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: certTypeList,
    },
    {
      type: "date-picker",
      placeholder: "过户日期",
      prop: "transferOwnershipDate",
      label: "过户日期",
      attrs: {
        clearable: true,
        type: "date",
        "range-separator": "~",
        editable: false,
        "value-format": "YYYY-MM-DD",
      },
    },
    {
      type: "input",
      placeholder: "行驶区域",
      label: "行驶区域",
      prop: "driveArea",
      attrs: {
        type: "textarea",
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input-number",
      label: "已使用年限(年)",
      prop: "serviceYears",
      placeholder: "已使用年限(年)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 2,
      },
    },
    {
      type: "input-number",
      label: "年平均行驶里程",
      prop: "annualAeragemile",
      placeholder: "年平均行驶里程",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },

    {
      type: "input-number",
      label: "年平均行驶里程",
      prop: "annualAeragemile",
      placeholder: "年平均行驶里程",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    {
      type: "input",
      placeholder: "车主姓名",
      label: "车主姓名",
      prop: "carName",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "车主手机",
      prop: "carPhone",
      placeholder: "车主手机",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
      rules: phoneRules,
    },
    {
      type: "select",
      placeholder: "车主证件类型",
      label: "车主证件类型",
      prop: "carDcumentType",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: certTypeList,
    },
    {
      type: "input",
      placeholder: "车主地址",
      label: "车主地址",
      prop: "carAddress",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      placeholder: "车主证件号码",
      label: "车主证件号码",
      prop: "carIdNum",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
  ];

  /**
  5、出险信息
  1、出险次数-accidentNum
  2、出险情况-accidentDesc
 */

  const accidentList = [
    {
      type: "input-number",
      label: "出险次数",
      prop: "accidentNum",
      placeholder: "出险次数",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    {
      type: "input",
      placeholder: "出险情况",
      label: "出险情况",
      prop: "accidentDesc",
      attrs: {
        type: "textarea",
        style: { width: "100%" },
        clearable: true,
      },
    },
  ];

  /**
  6、商业统筹信息

  1、标准统筹费(元)-必填-field1
  2、执行折扣(%)-必填-field2
  3、应缴统筹费(元)-必填-field3
  4、返点比率(%)-必填-field4
  5、返点金额(元)-field5
  6、实收筹费(元)-必填-field6

    7、统筹列表 #coordinateItems
    字段-
    1、统筹项目(复选框加文字)-（玻璃单独破碎统筹-特殊处理）-field7
    2、统筹额度下拉-(1000-1000万)-field8
    3、标准统筹费-field9
    4、政策折扣率(%)-field10
    5、应缴统筹费-field11

 */

  const businessCoordinateList = [
    {
      requiredFlag: true,
      type: "input-number",
      label: "标准统筹费(元)",
      prop: "field1",
      placeholder: "标准统筹费(元)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    {
      requiredFlag: true,
      type: "input-number",
      label: "执行折扣(%)",
      prop: "field2",
      placeholder: "执行折扣(%)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    {
      requiredFlag: true,
      type: "input-number",
      label: "应缴统筹费(元)",
      prop: "field3",
      placeholder: "应缴统筹费(元)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    {
      requiredFlag: true,
      type: "input-number",
      label: "返点比率(%)",
      prop: "fiel4",
      placeholder: "返点比率(%)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    {
      requiredFlag: true,
      type: "input-number",
      label: "返点金额(元)",
      prop: "field5",
      placeholder: "返点金额(元)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    {
      requiredFlag: true,
      type: "input-number",
      label: "实收筹费(元)",
      prop: "field6",
      placeholder: "实收筹费(元)",
      attrs: {
        controls: false,
        clearable: true,
        min: 0,
        precision: 0,
      },
    },
    { colConfig: { span: 24 }, slot: "#coordinateItems" },
  ];

  /**
  7、统筹单发票
  1、发票-下拉列表-field12-1
  2、开票类别-field13-1
  3、发票类型-field14-1
  4、购买方名称-field15-1
  5、证件类型-下拉--field16
  6、证件号码-field17-1
  7、纳税人识别码-field18-1
  8、开户行-field19-1
  9、对公账号-field20-1
  10、电话-field21-1
  11、地址-field22-1
  12、发票开具备注-field23
  13、发票开具金额-field24
  14、发票邮寄地址-field25
  15、收件人姓名-field26
  15、收件人电话-field27
  16、快递单号-field28
 */

  const masterOrderList = [
    {
      type: "select",
      placeholder: "发票",
      prop: "field12",
      label: "发票",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: invoiceList,
    },

    {
      type: "select",
      placeholder: "开票类别",
      prop: "field13",
      label: "开票类别",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: invoiceTypeList,
    },
    {
      type: "select",
      placeholder: "发票类别",
      prop: "field14",
      label: "发票类别",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: invoiceTypeList,
    },
    {
      type: "input",
      placeholder: "购买方名称",
      label: "购买方名称",
      prop: "field15",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "select",
      placeholder: "证件类型",
      prop: "field16",
      label: "证件类型",
      attrs: {
        filterable: true,
        clearable: true,
        style: {
          width: "100%",
        },
      },
      children: certTypeList,
    },
    {
      type: "input",
      placeholder: "证件号码",
      label: "证件号码",
      prop: "field17",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      placeholder: "纳税人识别码",
      label: "纳税人识别码",
      prop: "field18",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      placeholder: "开户行",
      label: "开户行",
      prop: "field19",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      placeholder: "对公账号",
      label: "对公账号",
      prop: "field20",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "手机号",
      prop: "field21",
      placeholder: "手机号",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
      rules: phoneRules,
    },
    {
      type: "input",
      label: "地址",
      prop: "field22",
      placeholder: "地址",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "发票开具备注",
      prop: "field23",
      placeholder: "发票开具备注",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "发票开具金额",
      prop: "field24",
      placeholder: "发票开具金额",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "发票邮寄地址",
      prop: "field25",
      placeholder: "发票邮寄地址",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "收件人姓名",
      prop: "field26",
      placeholder: "收件人姓名",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
    {
      type: "input",
      label: "收件人电话",
      prop: "field27",
      placeholder: "收件人电话",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
      rules: phoneRules,
    },
    {
      type: "input",
      label: "快递单号",
      prop: "field28",
      placeholder: "快递单号",
      attrs: {
        style: { width: "100%" },
        clearable: true,
      },
    },
  ];

  /**
 
  8、投统资料信息
  1、影像资料文件-field29
  2、资料备注-field30

  简单点就取消确定就好了
  9、按钮
  预保存-提交统筹单审核
 */

  const investmentDataList = [
    {
      slot: "field29",
      label: "影像资料文件",
    },
    {
      colConfig: { span: 24 },
      type: "input",
      label: "资料备注",
      prop: "field30",
      placeholder: "资料备注",
      attrs: {
        type: "textarea",
        style: { width: "100%" },
        clearable: true,
      },
    },
  ];

  const list = [
    ...planList,
    ...participantList,
    ...proxySignList,
    ...carList,
    ...accidentList,
    ...businessCoordinateList,
    ...masterOrderList,
    ...investmentDataList,
  ];

  addProperty(list);
  return list;
};
requestFormOptions.value = createRequestFormOptions();

const getFormData = () => {
  return formData.value;
};
</script>
